/******************************************************************************
	This file is a part of the Snapshot Bioinformatics Project

	Copyright (C) 2012-2013 Jarom Schow

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#ifndef SNAPSHOT_GENE_MODEL_H
#define SNAPSHOT_GENE_MODEL_H

#include <QtGui/QSortFilterProxyModel>

class SnapshotGeneCollection;

class SnapshotGeneModel : public QAbstractItemModel {
	Q_OBJECT
public:
	SnapshotGeneModel();
	virtual ~SnapshotGeneModel();

	void	setGenes( SnapshotGeneCollection *genes );

	virtual QModelIndex		index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;
	virtual QModelIndex		parent( const QModelIndex &index ) const;
	virtual int				rowCount( const QModelIndex &parent = QModelIndex() ) const;
	virtual int				columnCount( const QModelIndex & parent = QModelIndex() ) const;
	virtual Qt::ItemFlags	flags( const QModelIndex &index ) const;
	virtual QVariant		data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
	virtual QVariant		headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
	virtual bool			setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );

private slots:

	void	updateData();

private:

	SnapshotGeneCollection	*m_genes;
};

class SnapshotGeneProxyModel : public QSortFilterProxyModel {
	Q_OBJECT
public:
	SnapshotGeneProxyModel();
	virtual ~SnapshotGeneProxyModel();

	void	setGenes( SnapshotGeneCollection *genes );

protected:

	virtual bool	filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const;

private:

	SnapshotGeneModel		*m_sourceModel;
	SnapshotGeneCollection	*m_genes;
};

#endif // SNAPSHOT_GENE_MODEL_H